[JMSPublishFilters] Do not filter messages during broker shutdown #140
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
The JMSPublishFilters enqueue the task to filter messages in the topicOrderedExecutor threadpool, that is beeing shutdown here.
The Broker interceptors are stopped before that point, here and closing the interceptor also closes the Classloader that loaded the .nar file.
So there is a possibility for the Broker Interceptor code to be executed after the classloader is closed, resulting in errors like this:
Solution:
Intercept the closing of the broker and stop applying filters, in any case, even if the interceptor would have tried to persist a acknoledgment for a message, that would have been probably lost, so this is not a big deal.
Alternative solution (rejected):
Execute the filtering logic in the same thread as the onPublish callback: this would slow down too much the write path.
Alternative solution (rejected):
Keep a reference to all the pending "filtering actions" and wait for all of them during the broker shutdown. As they are expensive operations, that would slow down the shutdown of the broker, but we want the broker to shutdown as quickly as possible.